package com.bite.friend.rabbit;

import com.bite.api.domain.dto.JudgeSubmitDTO;
import com.bite.common.core.constants.RabbitMQConstants;
import com.bite.friend.domain.user.dto.UserSubmitDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class JudgeProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void submit(JudgeSubmitDTO judgeSubmitDTO) {
        try {
            rabbitTemplate.convertAndSend(RabbitMQConstants.OJ_JUDGE_QUEUE, judgeSubmitDTO);
        } catch (Exception e) {
            log.error("RabbitMQ出现异常 e: {}", e.toString());
            throw e;
        }
    }
}
